package admin

import (
	"github.com/gin-gonic/gin"
	"go_my_framework/app/service"
	"go_my_framework/util/base"
	"html/template"
)

// 首页
func Index(c *gin.Context) {
	// 用户信息
	adminSvc := service.AdminService{}
	_, roleId, username, _, purviewIds := adminSvc.GetAdminSession(c)

	// 根据角色权限展示菜单
	purviewSvc := service.PurviewService{}
	treeHtml := purviewSvc.GetMenusTree(roleId, purviewIds)

	// 渲染html页面
	base.Html(c, "/admin/index/index", gin.H{
		"username": username,
		"treeHtml": template.HTML(treeHtml)},
	)
}